package hdb.controller;

import hdb.dao.LagerTypDao;
import hdb.om.LagerTyp;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class SaveLagerTyp extends AbstractController {
	private LagerTypDao lagertypDao;

	public void setLagertypDao(LagerTypDao lagertypDao) {
		this.lagertypDao = lagertypDao;
	}

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest req,
			HttpServletResponse resp) throws Exception {
		int id = Integer.parseInt(req.getParameter("id"));
		String bez = req.getParameter("bezeichnung");
		
		if (id == 0) {
			lagertypDao.create(bez);
		} else {
			lagertypDao.modify(id, bez);
		}
		return new ModelAndView("home");
	}

}
